$(function () {
	var pages;
    var html='<ul class="am-list">';
    $('.am-list-news-bd').html(html);
    ym.ajax({
        url:"/course/queryCoursePackage",
        success:function (data) {
        	if(data.res == 1){
        		var htmlli='';
	            console.log(data);
	            pages = data.obj.pageNum;
	            if(data.obj.results.length > 0){
	            	for(var i=0;i<data.obj.results.length;i++){
						var zhi = data.obj.results[i];
		                htmlli+='<li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left" onclick="javascript:window.location.href=\'packagedetails.html?coursePackageId='+data.obj.results[i].coursePackageId+'\'">\n' 
	                   htmlli+= '<div class="am-u-sm-3 am-list-thumb">\n' 
	                    htmlli+='<a class="">\n' 
	                    htmlli+='<img src="'+data.obj.results[i].attachmentUrl+'" alt="疫苗！"/>\n' 
	                   htmlli+= '</a>\n' 
	                    htmlli+='</div>\n' 
	                    htmlli+='<div class=" am-u-sm-8 am-list-main w72">\n' 
	                    htmlli+='<h3 class="alt w100"><a class="w80 twospace" style="display: inline-block;">'+data.obj.results[i].coursePackageName+'</a>'
			            htmlli+=	'<p class="floatr font13 colorb6cce fontw" style="margin-top:1px">节数:<i>'+data.obj.results[i].total+'</i></p>'
			             htmlli+=  '</h3>\n'
	                   htmlli+= '<p class="learning">\n' 
	                   htmlli+= '<span>已售:'+data.obj.results[i].saleTotalNumber+'</span>\n' 
	                   htmlli+= '<!--两种情况-->\n' 
	                   htmlli+= '<span class="price">￥'+data.obj.results[i].discountPrice/100+'</span>\n' 
	                   htmlli+= '<!--<span class="free">免费</span>-->\n' 
	                   htmlli+= '</p>\n' 
	                   htmlli+= '</div>\n' 
	                   htmlli+= '</li>';
		             }
	            	$('.am-list').append(htmlli);
	            }else{
	            	htmlli = '<li class="am-text-center"><img style="height:150px" src="../img/no.jpg"></li>';
					$('.am-list').append(htmlli);
	            }
	            
	            if(data.obj.totalRecord > 5){
					$('.more').removeClass('none');
				}
        	}else{console.log("数据获取失败！")}
        }
    })
    
    /*点击查看更多*/
	$('body').on('click','.more',function(){
		$("#my-modal-loading").modal('open');
		pages = pages + 1;
		ym.ajax({
			url:"/course/queryCoursePackage",
			param:{ 
				pageNum:pages,
			},
			success:function(data){
				setTimeout(function(){
					$("#my-modal-loading").modal('close');
				},300)
				console.log(data);
				var htmlli = "";
				if(data.res ==1){
					for(var i=0;i<data.obj.results.length;i++){
						var zhi = data.obj.results[i];
		                htmlli+='<li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left" onclick="javascript:window.location.href=\'packagedetails.html?coursePackageId='+data.obj.results[i].coursePackageId+'\'">\n' 
	                   htmlli+= '<div class="am-u-sm-3 am-list-thumb">\n' 
	                    htmlli+='<a class="">\n' 
	                    htmlli+='<img src="'+data.obj.results[i].attachmentUrl+'" alt="疫苗！"/>\n' 
	                   htmlli+= '</a>\n' 
	                    htmlli+='</div>\n' 
	                    htmlli+='<div class=" am-u-sm-8 am-list-main w72">\n' 
	                   	htmlli+='<h3 class="alt w100"><a class="w80 twospace" style="display: inline-block;">'+data.obj.results[i].coursePackageName+'</a>'
			            htmlli+=	'<p class="floatr font13 colorb6cce fontw" style="margin-top:1px">节数:<i>'+data.obj.results[i].total+'</i></p>'
			             htmlli+=  '</h3>\n'
	                    
	                   htmlli+= '<p class="learning">\n' 
	                   htmlli+= '<span>已售:'+data.obj.results[i].saleTotalNumber+'</span>\n' 
	                   htmlli+= '<!--两种情况-->\n' 
	                   htmlli+= '<span class="price">￥'+data.obj.results[i].discountPrice/100+'</span>\n' 
	                   htmlli+= '<!--<span class="free">免费</span>-->\n' 
	                   htmlli+= '</p>\n' 
	                   htmlli+= '</div>\n' 
	                   htmlli+= '</li>';
		             }
	            	$('.am-list').append(htmlli);
					if(data.obj.results.length < 5){
						$('.more').html('');
						$('.more').html('<p>到底啦</p>');
						$('.more').removeClass('more');
					}
				}else{console.log("数据获取失败！")}
			}
		});
	})

})